<template>
<div class="app-container">
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>用户</span>
    </div>
    <div>
      <el-form :rules="rules" ref="targetForm" :model="temp" label-width="150px" label-position='right' size="small">
        <el-row :gutter="5">
          <el-col :span="12">
            <el-form-item label="所属组织" prop="ouinfoIdOzOrgOuinfoName">
              <el-input v-model="temp.ouinfoIdOzOrgOuinfoName" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="5">
          <el-col :span="12">
            <el-form-item label="人员姓名" prop="name">
              <el-input v-model="temp.name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户状态" prop="status">
              <el-radio v-model="temp.status" v-for="item in statusOptions" :key="item.key" :label="item.key">{{item.display_name}}</el-radio>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="5">
          <el-col :span="12">
            <el-form-item label="登录名称" prop="loginName">
              <el-input v-model="temp.loginName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="排序号" prop="orderNo">
              <el-input v-model="temp.orderNo"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-row :gutter="5">
        <el-col style="text-align: right;">
          <el-button size="small" class="filter-item" type="primary" @click="saveData">保 存</el-button>
          <el-button size="small" class="filter-item" type="primary" @click="closeSelf">关 闭</el-button>
        </el-col>
      </el-row>
    </div>
  </el-card>
</div>
</template>

<script>
import {
  // updateItem,
  compositeSelect
} from '@/api/systemManage/partJobManagement'
import {
  statusOptions,
  yesOrNoOptions,
  jobtitleOptions,
  joblevelOptions
} from '@/utils/allOptions'
export default {
  name: 'editUser',
  data() {
    return {
      rules: {
        name: [{
          required: true,
          message: '请输入用户姓名',
          trigger: 'blur'
        },
        {
          min: 0,
          max: 255,
          message: '长度在 0 到 255 个字符',
          trigger: 'blur'
        },
        {
          max: 255,
          message: '最大 255 个字符',
          trigger: 'blur'
        }
        ],
        loginName: [{
          required: true,
          message: '请输入登录名称',
          trigger: 'blur'
        },
        {
          min: 0,
          max: 255,
          message: '长度在 0 到 255 个字符',
          trigger: 'blur'
        },
        {
          max: 255,
          message: '最大 255 个字符',
          trigger: 'blur'
        }
        ],
        orderNo: [{
          required: true,
          message: '请输入排序号',
          trigger: 'blur'
        },
        {
          min: 0,
          max: 255,
          message: '长度在 0 到 255 个字符',
          trigger: 'blur'
        },
        {
          max: 255,
          message: '最大 255 个字符',
          trigger: 'blur'
        }
        ]
      },
      temp: {
        id: '',
        ouinfoId: '',
        status: '0',
        innerFlag: 'Y',
        name: '',
        namePinyin: '',
        code: '',
        groupType: '',
        memos: '',
        ouinfoIdOzOrgOuinfoName: ''
      },
      targetUserId: '',
      // -------Options-----------
      statusOptions,
      yesOrNoOptions,
      jobtitleOptions,
      joblevelOptions
    }
  },
  methods: {
    closeSelf() {
      this.$router.push({ name: 'partJobManagement' })
    },
    saveData() {
      this.$refs.targetForm.validate(valid => {
        if (valid) {
          this.temp.password = '123456'
          // updateItem(this.$route.params.id, this.temp).then(response => {
          //   this.$notify({
          //     title: '成功',
          //     message: '创建成功',
          //     type: 'success',
          //     duration: 2000
          //   })
          //   this.$router.push({ name: 'partJobManagement' })
          //   this.targetUserId = response.data.data.id
          // })
        }
      })
    }
  },
  mounted() {
    compositeSelect({ id: this.$route.params.id }).then(response => {
      const resData = response.data.data
      this.temp = Object.assign({}, resData) // copy obj   this.subSystemsOptions.push(input);
    })
  }
}
</script>

